package com.game.euchre;

public class Player extends PlayerActionsImpl {
	public boolean team1selectTrump;
	Trump location = new Trump();
	int dealerLocation = location.dealerLocation;
	int currentLocation;
	int teamWinning;
	int team1tricks;
	int team2tricks;
	TrickEvaluator determineTrickWinner;
	HandEvaluator determineHandWinner;
	//Card hand1 = new Dealer().Hand();

	Card hand1[] = new Dealer().hand();
	Card hand2[] = new Dealer().hand();
	Card hand3[] = new Dealer().hand();
	Card hand4[] = new Dealer().hand();
	Card kitty[] = new Dealer().kitty();
	Card winningTrick;
	Card faceUp;

	boolean cannotpass = false;
	
	
	//testing
	//determine the card that needs to be discarded by the dealer.
	public int dealerDiscard(){
		int cardobj = 3;
		
		return cardobj;
	}
	
	//determine the suit value pressed.
	public int suitValue(){
		int suit = 3;
		
		return suit;
	}
	//testing
	
	
	public void dealerPickUp(){
		
		if (currentLocation < 4){
			
		 faceUp = kitty[0];
		 currentLocation = dealerLocation;
		 
		 //Dealer Input send back of what card to discard. Aaron.
		 int dealerChoose = dealerDiscard();
		 
		 hand4[dealerChoose] = kitty[0];
		 
		 //TODO
		 location.trumpValues(kitty[0].getSuit(), hand1, hand2, hand3, hand4);
		}
	}
	
	public void playerChoice(){
		
		if (currentLocation > 4 && currentLocation < 8){
			int suit = suitValue();
			
			location.trumpValues(suit, hand1, hand2, hand3, hand4);
		}
		
		//stick the dealer
		else if (currentLocation == 8){
			
			cannotpass = true;
		}
		
	}
	
	public void pass(){
		
		// also gray out button on activity
		if (cannotpass == false)
		{
			currentLocation = Trump.currentPlayer(currentLocation);
		}
	}
	
	public void playCard(Card playedCard, int player){
		
		if (currentLocation + 1 == player)
		{
			winningTrick = playedCard;
			teamWinning = player;
		}
		
		else
		{
			winningTrick = determineTrickWinner.determineTrickWinner(playedCard, winningTrick);

			if (winningTrick == playedCard)
			{
				teamWinning = player;
			}
			if (currentLocation == player)
			{
				if (teamWinning == 1 || teamWinning == 3)
				{
					team1tricks++;
					//team 1
				}
				
				else if (teamWinning == 2 || teamWinning == 4)
				{
					team2tricks++;
					//team 2
				}
				
				// pass winning hand to hand evaluator
			}
				
		}
		
		//Hand evaluator should find out who picked trump and calculate how many points should be assignmed to the respective team. And accumulate at GameEvaluator
		determineHandWinner.winninghand(team1tricks, team2tricks, team1selectTrump);
		currentLocation++;
		// TODO: All this method should do is use the current card played and compare it to the previous one.
		// once the winner is determined at the end of the trick. HandEvaluator method should be ran and should determine how many points are assigned.
		// Inside of HandEvaluator should call GameEvaluator that has an accumulator that determines if someone has won. 
		
		// call trick Evaluator. Aaron will input hand Card object and the int of the player (0-3).
		
	}
	
	public void goAlone(int player){
		
		if (currentLocation <4)
		{
			dealerPickUp();
			
			// have Aaron create a method that will disable the goAlone players' team mate. Pass 'player' to the method.
		}
		
		else if ( currentLocation > 4 && currentLocation < 8)
		{
			playerChoice();
			
			// have Aaron create a method that will disable the goAlone players' team mate. Pass 'player' to the method.
		}
	}
}
